#include "qsswindow.h"

#include "qsseditor.h"
#include "previewer.h"

#include "DockManager.h"
#include "DockWidget.h"

using namespace ads;

QssWindow::QssWindow(QWidget *parent)
    : QMainWindow{parent}
{

    CDockManager *dockManager = new CDockManager(this);

    CDockWidget *dockWidget = new CDockWidget(tr("Qss Editor"));
    m_qssEditor = new QssEditor(this);
    dockWidget->setWidget(m_qssEditor);
    dockManager->addDockWidget(ads::LeftDockWidgetArea, dockWidget);

    dockWidget = new CDockWidget(tr("Preview style"));
    m_previewer = new Previewer(this);
    dockWidget->setWidget(m_previewer);
    dockManager->addDockWidget(ads::RightDockWidgetArea, dockWidget);

    connect(m_qssEditor, SIGNAL(applyCss(QString)), m_previewer, SLOT(slotApplyCss(QString)));
    connect(m_qssEditor, SIGNAL(applyCss(QString)), this, SIGNAL(applyCss(QString)));
}

void QssWindow::addPreviewWidget(QWidget *w, QString title)
{
    m_previewer->addTab(w, title);
}
